package com.beta.em.order;

import java.util.Objects;

/**
 * Created by lichao on 2016/11/24.
 */
public enum PayStatus {

    PAID_INIT("paid_init", "-"),
    FREIGHT_UNPAID("freight_unpaid", "代付运费"),
    FREIGHT_PAID("freight_paid", "已付运费"),
    UNPAID("unpaid", "未付款"),
    OWNED("owned", "代缴款"),
    UNCHECKED("unchecked", "待核实"),
    PAID("paid", "已付款"),
    FAILED("failed", "付款失败");

    private String value;
    private String cnValue;

    PayStatus(String value, String cnValue) {
        this.value = value;
        this.cnValue = cnValue;
    }

    public String getValue() {
        return value;
    }

    public String getCnValue() {
        return cnValue;
    }

    public static PayStatus getPayStatus(String value) {
        for (PayStatus payStatus : values()) {
            if (payStatus.getValue().equals(value)) {
                return payStatus;
            }
        }
        return null;
    }

    public static String getCnValue(String value) {
        PayStatus payStatus = getPayStatus(value);
        if (Objects.nonNull(payStatus)) {
            return payStatus.getCnValue();
        } else {
            return "";
        }
    }

}
